package com.xnyzc.lhy.mis.controller.cmsapi.driver;

import com.xnyzc.lhy.common.entity.Rv;
import com.xnyzc.lhy.mis.entity.cms.driver.DriverUserInfo;
import com.xnyzc.lhy.mis.service.cms.driver.DriverManageService;
import com.xnyzc.lhy.mis.service.sys.OaSysNationService;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author zhaolijie
 * @date 2019-08-22 10:42
 */
@RestController
@RequestMapping("/cmsapi/driver")
public class DriverManageController {

    @Autowired
    private DriverManageService driverManageService;
    @Autowired
    private OaSysNationService oaSysNationService;


    @ApiOperation(value = "queryPersonSearchAsync", notes = "根据订单号查询订单关联的司机s和应商信息")
    @GetMapping(value = "/queryPersonSearchAsync")
    public Rv queryPersonAsync(@ApiParam(name = "orderNo", value = "订单号") String orderNo ) {
        return driverManageService.queryPersonSearchAsync(orderNo);
    }

    @ApiOperation(value = "根据司机id将司机拉入黑名单", notes = "根据司机id将司机拉入黑名单或者将司机从黑名单恢复")
    @GetMapping(value = "/putOrPopDriverBlacklist")
    public Rv putOrPopDriverBlacklist(@ApiParam(name = "driverId", value = "司机id") Long driverId,
                                      @ApiParam(name = "isBlocked", value = "黑名单标记") Integer isBlocked) {
        return driverManageService.putOrPopDriverBlocklist(driverId, isBlocked);
    }

    @ApiOperation(value = "根据司机id查询司机实时位置经纬度等信息", notes = "根据司机id查询司机实时位置经纬度等信息")
    @GetMapping(value = "/getThisDriverPosition")
    public Rv getThisDriverPosition(@ApiParam(name = "driverId", value = "司机id") Long driverId) {
        return driverManageService.getThisDriverPosition(driverId);
    }

    @ApiOperation(value = "根据车牌号或司机姓名查询司机信息", notes = "根据车牌号或司机姓名查询司机信息")
    @PostMapping(value = "/getDriverInfoByNameAndVehicle")
    public Rv getDriverInfoByNameAndVehicle(@ApiParam(name = "driverName", value = "司机姓名") String driverName,
                                            @ApiParam(name = "vehNo", value = "车牌号") String vehNo) {
        return driverManageService.getDriverInfoByNameAndVehicle(driverName, vehNo);
    }

    @ApiOperation(value = "查询司机实时位置经纬度等信息", notes = "查询司机实时位置经纬度等信息")
    @PostMapping(value = "/getAllDriverGPSInfo")
    public Rv getAllDriverGPSInfo() {
        return driverManageService.getAllDriverGPSInfo();
    }

    @ApiOperation(value = "根据司机Id获取证件图片信息", notes = "根据司机Id获取证件图片信息")
    @GetMapping(value = "/getDriverLicenseImgInfoById")
    public Rv getDriverLicenseImgInfoById(
            @ApiParam(name = "driverId", value = "司机的ID") Long driverId) {
        return driverManageService.getDriverLicenseImgInfoById(driverId);
    }

    ;

    /**
     * 司机信息管理列表查询
     *
     * @return
     */
    @ApiOperation(value = "司机信息管理列表查询", notes = "司机信息管理列表查询")
    @GetMapping(value = "/getDriverManagementList")
    public Rv getDriverManagementList(
            @ApiParam(name = "current", value = "需要查询的页码") Integer current,
            @ApiParam(name = "pageSize", value = "需要查询的页码") Integer pageSize,
            @ApiParam(name = "cityCode", value = "城市") String cityCode,
            @ApiParam(name = "officeId", value = "部门ID") Long officeId,
            @ApiParam(name = "accountStatus", value = "账号状态") String accountStatus,
            @ApiParam(name = "driverPhone", value = "手机号码") String driverPhone,
            @ApiParam(name = "driverName", value = "司机姓名") String driverName,
            @ApiParam(name = "service", value = "业务类型") String service,
            @ApiParam(name = "vehicleTeam", value = "车队") String vehicleTeam,
            @ApiParam(name = "driverType", value = "司机类型") String driverType,
            @ApiParam(name = "vehNo", value = "车牌号") String vehNo,
            @ApiParam(name = "acceptancOrderStatus", value = "出车状态") Integer acceptancOrderStatus
    ) {
        return driverManageService.getDriverManagementList(current, pageSize, cityCode, officeId, accountStatus, driverPhone, driverName, service, vehicleTeam, driverType, vehNo, acceptancOrderStatus);
    }

    /**
     * 司机信息管理列表查询导出
     *
     * @return
     */
    @ApiOperation(value = "司机信息管理列表查询导出", notes = "司机信息管理列表查询导出")
    @GetMapping(value = "/getDriverManagementListExport")
    public Rv getDriverManagementListExport(
            @ApiParam(name = "current", value = "需要查询的页码") Integer current,
            @ApiParam(name = "pageSize", value = "需要查询的页码") Integer pageSize,
            @ApiParam(name = "cityCode", value = "城市") String cityCode,
            @ApiParam(name = "accountStatus", value = "账号状态") String accountStatus,
            @ApiParam(name = "driverPhone", value = "手机号码") String driverPhone,
            @ApiParam(name = "driverName", value = "司机姓名") String driverName,
            @ApiParam(name = "service", value = "业务类型") String service,
            @ApiParam(name = "vehicleTeam", value = "车队") String vehicleTeam,
            @ApiParam(name = "driverType", value = "司机类型") String driverType,
            @ApiParam(name = "vehNo", value = "车牌号") String vehNo,
            @ApiParam(name = "acceptancOrderStatus", value = "出车状态") Integer acceptancOrderStatus
    ) {
        return driverManageService.getDriverManagementListExport(current, pageSize, cityCode, accountStatus, driverPhone, driverName, service, vehicleTeam, driverType, vehNo, acceptancOrderStatus);
    }

    /**
     * 获取司机列表页面模糊下拉选
     *
     * @return
     */
    @ApiOperation(value = "获取司机列表页面模糊下拉选", notes = "获取司机列表页面模糊下拉选")
    @GetMapping(value = "/getSelectList")
    public Rv getSelectList() {
        return driverManageService.getSelectList();
    }


    /**
     * 司机管理查看详情
     *
     * @param driverId
     * @return
     */
    @ApiOperation(value = "司机信息管理查看司机详情", notes = "司机信息管理查看司机详情")
    @GetMapping(value = "/getDriverDetails")
    public Rv getDriverDetails(@ApiParam(name = "driverId", value = "司机的ID") Long driverId) {
        return driverManageService.getDriverDetails(driverId);
    }

    /**
     * 添加司机信息
     *
     * @param driverUserInfo:接收司机信息的实体类
     * @return
     */
    @ApiOperation(value = "添加司机信息", notes = "添加司机信息")
    @PostMapping(value = "/addDriver")
    public Rv addDriver(
            @ApiParam(name = "driverUserInfo", value = "司机信息实体类") @RequestBody DriverUserInfo driverUserInfo) {
        return driverManageService.addDriver(driverUserInfo);
    }

    /**
     * 修改司机信息
     *
     * @param driverUserInfo:接收司机信息的实体类
     * @return
     */
    @ApiOperation(value = "修改司机信息", notes = "修改司机信息")
    @PostMapping(value = "/updateDriver")
    public Rv updateDriver(
            @ApiParam(name = "driverUserInfo", value = "司机信息实体类") @RequestBody DriverUserInfo driverUserInfo) {
        return driverManageService.updateDriver(driverUserInfo);
    }

    /**
     * 删除司机信息
     *
     * @param driverUserInfo:接收司机信息的实体类
     * @return
     */
    @ApiOperation(value = "删除司机信息", notes = "删除司机信息")
    @PostMapping(value = "/deleteDriver")
    public Rv deleteDriver(
            @ApiParam(name = "officeParam", value = "司机信息实体类") @RequestBody DriverUserInfo driverUserInfo) {
        return driverManageService.deleteDriver(driverUserInfo);
    }

    /**
     * 获取司机车辆关联管理信息
     *
     * @param current:需要查询的页码
     * @return
     */
    @ApiOperation(value = "获取司机车辆关联管理信息", notes = "获取司机车辆关联管理信息")
    @GetMapping(value = "/getDriverVehicle")
    public Rv getDriverVehicle(@ApiParam(name = "current", value = "需要查询的页码") Integer current) {
        return driverManageService.getDriverVehicle(current);
    }

    /**
     * 模糊查询司机关联管理信息
     *
     * @return
     */
    @ApiOperation(value = "司机信息管理列表模糊查询", notes = "司机信息管理列表模糊查询")
    @GetMapping(value = "/getDriverVehicleLike")
    public Rv getDriverVehicleLike(
            @ApiParam(name = "current", value = "需要查询的页码") Integer current,
            @ApiParam(name = "driverOnlineStatus", value = "司机在线状态（0：在线、1：下在线线）") String driverOnlineStatus,
            @ApiParam(name = "isUse", value = "是否正在使用(0：否、1：是）") String isUse,
            @ApiParam(name = "driverPhone", value = "手机号码") String driverPhone,
            @ApiParam(name = "driverName", value = "用户姓名") String driverName
    ) {
        return driverManageService.getDriverVehicleLike(current, driverOnlineStatus, isUse, driverPhone, driverName);
    }

    /**
     * 获取下载模板数据
     *
     * @return
     */
    @ApiOperation(value = "获取下载模板数据", notes = "获取下载模板数据")
    @GetMapping(value = "/getDriverDownloadTemplate")
    public Rv getDriverDownloadTemplate() {
        return driverManageService.getDriverDownloadTemplate();
    }

    /**
     * 更换车辆查询
     *
     * @return
     */
    @ApiOperation(value = "更换车辆查询", notes = "更换车辆查询")
    @GetMapping(value = "/getChangeVehicleList")
    public Rv getChangeVehicleList(
            @ApiParam(name = "current", value = "需要查询的页码") Integer current,
            @ApiParam(name = "size", value = "需要查询的页码") Integer size,
            @ApiParam(name = "vehNo", value = "车牌号") String vehNo
    ) {
        return driverManageService.getChangeVehicleList(current, size, vehNo);
    }

    /**
     * 更换车辆
     *
     * @return
     */
    @ApiOperation(value = "更换车辆查询", notes = "更换车辆查询")
    @GetMapping(value = "/getChangeVehicle")
    public Rv getChangeVehicle(
            @ApiParam(name = "driverId", value = "司机id") Long driverId,
            @ApiParam(name = "vehicleId", value = "车辆id") Long vehicleId
    ) {
        return driverManageService.getChangeVehicle(driverId, vehicleId);
    }

    /**
     * 解绑车辆
     *
     * @return
     */
    @ApiOperation(value = "解绑车辆", notes = "解绑车辆")
    @GetMapping(value = "/getUnbindVehicle")
    public Rv getUnbindVehicle(
            @ApiParam(name = "driverId", value = "司机id") Long driverId
    ) {
        return driverManageService.getUnbindVehicle(driverId);
    }

    /**
     * 司机已接单或者前往预约地点订单的预警
     *
     * @return
     */
   /* @ApiOperation(value = "司机已接单订单的预警", notes = "司机已接单订单的预警")
    @GetMapping(value = "/task/earlyWarning")
    public Rv earlyWarning() {
        return driverManageService.earlyWarning();
    }*/

    /**
     * 获取民族字典
     */
    @GetMapping("/getNation")
    public Rv getNation() {
        return oaSysNationService.getNation();
    }

}
